package com.zsk.okhttp;

import okhttp3.OkHttpClient;

public class HttpFactory {

	/**
	 * 是否忽略SSL证书
	 * 
	 * @param ignoreSSL
	 * @return
	 * @date 2020/04/16 14:49:38
	 */
	@SuppressWarnings("deprecation")
	public static OkHttpClient newOkHttpClient(boolean ignoreSSL) {
		if (!ignoreSSL)
			return new OkHttpClient();

		OkHttpClient.Builder builder = newHttpBuilder();
		builder.sslSocketFactory(SSLSocketClient.getSSLSocketFactory())
				.hostnameVerifier(SSLSocketClient.getHostnameVerifier());

		return builder.build();
	}

	public static OkHttpClient.Builder newHttpBuilder() {
		return new OkHttpClient.Builder();
	}

}
